<%@page import="com.softeem.encrypt.MD5"%>
<%@page import="com.softeem.sss.dto.User"%>
<%@page import="com.softeem.sss.dao.UserDAO"%>
<%@ page language="java" pageEncoding="UTF-8"%>
<%

	//获取前端页面提交过来的账号和密码
	String name = request.getParameter("username");
	String pwd = request.getParameter("password");
	
	//根据用户名查询用户
	UserDAO dao = new UserDAO();
	User user = dao.findByUsername(name);
	
	//对输入的密码加密处理
	pwd = new MD5().getMD5ofStr(pwd);
	
	if(user != null){
		if(user.getPassword().equals(pwd)){
			//登录成功(进入主页)
			//将用户信息存储在session中
			session.setAttribute("user", user);	
			response.sendRedirect("doList.jsp");
		}else{
			//密码错误(返回登录页)
			request.setAttribute("msg", "密码错误");
			request.getRequestDispatcher("login.jsp").forward(request, response);
		}
	}else{
		//账号不存在(返回登录页)
		request.setAttribute("msg", "账号不存在");
		request.getRequestDispatcher("login.jsp").forward(request, response);
	}
%>